package main.pak;

import opengl.Jayway;
import main.pak.R.id;
import toannm.ChoiceQuestion;
import toannm.MusicPlayer;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import animation.DragDropActivity;
import animation.DrawableAnimationTree;
import animation.Drawing;
import animation.MyDrag;
import animation.OurSurface;

public class MainActivity extends Activity {

	Button _cmd_choiceQuestion;
	Button _cmd_musicBackground;
	Button _cmd_drawAnimation;
	Button _cmd_haindActivity;
	Button _cmd_surfaceAnimation;
	Button _cmd_drawableAnimation;
	Button _cmd_view_animtion;
	Button _cmd_drag_drop;
	Button _cmd_opengl;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_menus);

		// Get Button object
		_cmd_choiceQuestion = (Button) findViewById(id.btnMultiquestion);
		_cmd_musicBackground = (Button) findViewById(id.btnPlayMusicBackground);
		_cmd_drawAnimation = (Button) findViewById(id.btnDrawAnimation);
		_cmd_surfaceAnimation = (Button) findViewById(id.btnSurfaceAnimation);
		_cmd_drawableAnimation = (Button) findViewById(id.btnDrawableAnimation);
		_cmd_drag_drop =(Button) findViewById(id.btnDragDrop);
		_cmd_opengl = (Button) findViewById(id.btnOpenGL1);
		
		_cmd_haindActivity = (Button) findViewById(id.btnHaiND);

		// Assign event
		_cmd_choiceQuestion.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItQuestion = new Intent(MainActivity.this,
						ChoiceQuestion.class);
				MainActivity.this.startActivity(ItQuestion);
			}
		});

		_cmd_musicBackground.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItMusic = new Intent(MainActivity.this,
						MusicPlayer.class);
				MainActivity.this.startActivity(ItMusic);
			}
		});

		_cmd_drawAnimation.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItDrawing = new Intent(MainActivity.this, Drawing.class);
				MainActivity.this.startActivity(ItDrawing);
			}
		});
		
		_cmd_drag_drop.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItDragDrop = new Intent(MainActivity.this, DragDropActivity.class);
				MainActivity.this.startActivity(ItDragDrop);
			}
		});


		_cmd_surfaceAnimation.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItDrawing = new Intent(MainActivity.this,
						OurSurface.class);
				MainActivity.this.startActivity(ItDrawing);
			}
		});

		_cmd_drawableAnimation.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItDrawing = new Intent(MainActivity.this,
						DrawableAnimationTree.class);
				MainActivity.this.startActivity(ItDrawing);
			}
		});
		
		_cmd_opengl.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent ItDrawing = new Intent(MainActivity.this,
						Jayway.class);
				MainActivity.this.startActivity(ItDrawing);
			}
		});

		_cmd_haindActivity.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent vIt = new Intent(MainActivity.this,
						haind.HaiNDActivity.class);
				startActivity(vIt);
			}
		});

	}

	@Override
	public void onBackPressed() {
		new AlertDialog.Builder(this)
				.setIcon(android.R.drawable.ic_dialog_alert)
				.setTitle("Closing Activity")
				.setMessage("Are you sure want to close this activity?")
				.setPositiveButton("Yes",
						new DialogInterface.OnClickListener() {

							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								finish();
							}
						}).setNegativeButton("No", null).show();
	}
}
